/******************************************************************************
 * Author:      671643387
 * Created:     2016/9/27
 *****************************************************************************/

/**
 * 加载器
 * @param onAllLoad
 * @constructor
 */
function Loader(onAllLoad){
    this.tasks = [];
    this.onAllLoad = onAllLoad;
}
Loader.prototype = {
    addLoad : function(task){
        this.tasks.push(task);
    },

    onLoad : function(task){
        var index = this.tasks.indexOf(task);
        if( index >= 0 ) {
            this.tasks.splice(index, 1);
            if( this.tasks.length == 0 ) {
                this.onAllLoad && this.onAllLoad();
            }
        }
    },
};

exports.Loader = Loader;